home *** CD-ROM | disk | FTP | other *** search
/ Shocking The Web CD-ROM / SHOCK_CD.ISO / pc / powerapp / animator.exe / gmd.dcr / 00003_MAIN SCRIPTS.ls < prev    next >
Encoding:
Text File  |  1996-05-07  |  13.7 KB  |  319 lines

  1. global gAnimSpeedSlider, myFileIO, gRadioCluster, gStartingPoint, gEndingPoint, cShowFrame, gLogoType, gAnimationStage, gCenterStage, gDisplayArea, gLogoAnimationStart, gLogoAnimationFrames, gAnimSpeed, gAnimationObjects, gDeathRow, gEnterPathButtonList, gExitPathButtonList, gDirectionButtonGridList, gEnterPathDirection, gExitPathDirection, cEnterPathAnimChannel, cExitPathAnimChannel, cLogoEnterChannel, cLogoHoldChannel, cLogoExitChannel, gGeneralSetting, gLoopCounter, gLoopMaximum, gbCanAnimate, gbPaused, gSpriteStack, gEnterTime, gHoldTime, gExitTime, gDelayTime, gCPU
  2.  
  3. on startMovie
  4.   set gAnimationObjects to [:]
  5.   set gDeathRow to []
  6.   sort(gAnimationObjects)
  7.   set the cpuHogTicks to 3600
  8. end
  9.  
  10. on initializeGlobals
  11.   set gEnterPathDirection to value(word 1 of field "EnterDir")
  12.   if gEnterPathDirection < 1 then
  13.     set gEnterPathDirection to 1
  14.   end if
  15.   set gExitPathDirection to value(word 1 of field "ExitDir")
  16.   if gExitPathDirection < 1 then
  17.     set gExitPathDirection to 1
  18.   end if
  19.   set cLogoEnterChannel to 1
  20.   set cLogoHoldChannel to 2
  21.   set cLogoExitChannel to 3
  22.   set cShowFrame to 7
  23.   set gEnterTime to value(word 1 of field "EnterTime")
  24.   set gHoldTime to value(word 1 of field "HoldTime")
  25.   set gExitTime to value(word 1 of field "ExitTime")
  26.   set gLoopMaximum to value(word 1 of field "PlayTimes")
  27.   set gDelayTime to value(word 1 of field "DelayTime")
  28.   set gAnimSpeed to value(word 1 of field "AnimSpeed")
  29.   set gLogoAnimationStart to value(word 1 of field "LogoStart")
  30.   set gLogoAnimationFrames to value(word 1 of field "LogoFrames")
  31.   set gGeneralSetting to value(word 1 of field "GeneralSetting")
  32.   set gbCanAnimate to 1
  33.   set gbPaused to 0
  34.   set gDisplayArea to rect(0, 0, the stageRight - the stageLeft, the stageBottom - the stageTop)
  35.   set gCenterStage to point((the stageRight - the stageLeft) / 2, (the stageBottom - the stageTop) / 2)
  36.   puppetSprite(cLogoEnterChannel, 1)
  37.   puppetSprite(cLogoHoldChannel, 1)
  38.   puppetSprite(cLogoExitChannel, 1)
  39.   resetPreview()
  40. end
  41.  
  42. on callAnimEngine
  43.   set activeObjectsCount to count(gAnimationObjects)
  44.   if activeObjectsCount > 0 then
  45.     repeat with objectNum = 1 to activeObjectsCount
  46.       stepAnimation(getAt(gAnimationObjects, objectNum))
  47.     end repeat
  48.     if count(gDeathRow) > 0 then
  49.       repeat with condemned in gDeathRow
  50.         death(getaProp(gAnimationObjects, condemned))
  51.       end repeat
  52.       set gDeathRow to []
  53.     end if
  54.     updateStage()
  55.   end if
  56. end
  57.  
  58. on updateAnimObjects whichItem
  59.   if whichItem = #enterPreview then
  60.     deleteProp(gAnimationObjects, cLogoEnterChannel)
  61.     setaProp(gAnimationObjects, cLogoEnterChannel, birth(script "AnimatorClass", [#channel: cLogoEnterChannel, #location: gStartingPoint, #frameDataStart: gLogoAnimationStart, #frameData: gLogoAnimationFrames, #everyFrame: 0, #pathData: #CALC, #soundType: #NULL, #soundName: #NULL, #iterations: 1, #frameRate: gAnimSpeed, #pauseState: 0, #visibleState: 0, #pathStartLoc: gStartingPoint, #pathEndLoc: gCenterStage, #animationTime: gEnterTime, #inkEffect: #MATTE, #loopAction: #pause, #completionAction: #pause]))
  62.     exit
  63.   end if
  64.   if whichItem = #holdPreview then
  65.     deleteProp(gAnimationObjects, cLogoHoldChannel)
  66.     setaProp(gAnimationObjects, cLogoHoldChannel, birth(script "AnimatorClass", [#channel: cLogoHoldChannel, #location: gCenterStage, #frameDataStart: gLogoAnimationStart, #frameData: gLogoAnimationFrames, #everyFrame: 0, #pathData: #CALC, #soundType: #NULL, #soundName: #NULL, #iterations: 1, #frameRate: gAnimSpeed, #pauseState: 1, #visibleState: 0, #pathStartLoc: gCenterStage, #pathEndLoc: gCenterStage, #animationTime: gHoldTime, #inkEffect: #MATTE, #loopAction: #pause, #completionAction: #pause]))
  67.     exit
  68.   end if
  69.   if whichItem = #exitPreview then
  70.     deleteProp(gAnimationObjects, cLogoExitChannel)
  71.     setaProp(gAnimationObjects, cLogoExitChannel, birth(script "AnimatorClass", [#channel: cLogoExitChannel, #location: gCenterStage, #frameDataStart: gLogoAnimationStart, #frameData: gLogoAnimationFrames, #everyFrame: 0, #pathData: #CALC, #soundType: #NULL, #soundName: #NULL, #iterations: 1, #frameRate: gAnimSpeed, #pauseState: 1, #visibleState: 0, #pathStartLoc: gCenterStage, #pathEndLoc: gEndingPoint, #animationTime: gExitTime, #inkEffect: #MATTE, #loopAction: #pause, #completionAction: #pause]))
  72.   end if
  73. end
  74.  
  75. on resetPreview
  76.   cursor(4)
  77.   set gLoopCounter to 0
  78.   set gbCanAnimate to 1
  79.   set logoWidth to the width of cast gLogoAnimationStart / 2
  80.   set logoHeight to the height of cast gLogoAnimationStart / 2
  81.   if gEnterPathDirection = 1 then
  82.     set gStartingPoint to point(the left of gDisplayArea, the top of gDisplayArea) - point(0, logoHeight)
  83.   else
  84.     if gEnterPathDirection = 2 then
  85.       set gStartingPoint to point(the left of gDisplayArea - ((the left of gDisplayArea - the right of gDisplayArea) / 2), the top of gDisplayArea) - point(0, logoHeight)
  86.     else
  87.       if gEnterPathDirection = 3 then
  88.         set gStartingPoint to point(the right of gDisplayArea, the top of gDisplayArea) - point(0, logoHeight)
  89.       else
  90.         if gEnterPathDirection = 4 then
  91.           set gStartingPoint to point(the left of gDisplayArea, the bottom of gDisplayArea - ((the bottom of gDisplayArea - the top of gDisplayArea) / 2)) - point(logoWidth, 0)
  92.         else
  93.           if gEnterPathDirection = 5 then
  94.             set gStartingPoint to gCenterStage
  95.           else
  96.             if gEnterPathDirection = 6 then
  97.               set gStartingPoint to point(the right of gDisplayArea, the bottom of gDisplayArea - ((the bottom of gDisplayArea - the top of gDisplayArea) / 2)) - point(-logoWidth, 0)
  98.             else
  99.               if gEnterPathDirection = 7 then
  100.                 set gStartingPoint to point(the left of gDisplayArea, the bottom of gDisplayArea) - point(0, -logoHeight)
  101.               else
  102.                 if gEnterPathDirection = 8 then
  103.                   set gStartingPoint to point(the right of gDisplayArea - ((the right of gDisplayArea - the left of gDisplayArea) / 2), the bottom of gDisplayArea) - point(0, -logoHeight)
  104.                 else
  105.                   if gEnterPathDirection = 9 then
  106.                     set gStartingPoint to point(the right of gDisplayArea, the bottom of gDisplayArea) - point(0, -logoHeight)
  107.                   end if
  108.                 end if
  109.               end if
  110.             end if
  111.           end if
  112.         end if
  113.       end if
  114.     end if
  115.   end if
  116.   if gExitPathDirection = 1 then
  117.     set gEndingPoint to point(the left of gDisplayArea, the top of gDisplayArea) - point(0, logoHeight)
  118.   else
  119.     if gExitPathDirection = 2 then
  120.       set gEndingPoint to point(the left of gDisplayArea - ((the left of gDisplayArea - the right of gDisplayArea) / 2), the top of gDisplayArea) - point(0, logoHeight)
  121.     else
  122.       if gExitPathDirection = 3 then
  123.         set gEndingPoint to point(the right of gDisplayArea, the top of gDisplayArea) - point(0, logoHeight)
  124.       else
  125.         if gExitPathDirection = 4 then
  126.           set gEndingPoint to point(the left of gDisplayArea, the bottom of gDisplayArea - ((the bottom of gDisplayArea - the top of gDisplayArea) / 2)) - point(logoWidth, 0)
  127.         else
  128.           if gExitPathDirection = 5 then
  129.             set gEndingPoint to gCenterStage
  130.           else
  131.             if gExitPathDirection = 6 then
  132.               set gEndingPoint to point(the right of gDisplayArea, the bottom of gDisplayArea - ((the bottom of gDisplayArea - the top of gDisplayArea) / 2)) - point(-logoWidth, 0)
  133.             else
  134.               if gExitPathDirection = 7 then
  135.                 set gEndingPoint to point(the left of gDisplayArea, the bottom of gDisplayArea) - point(0, -logoHeight)
  136.               else
  137.                 if gExitPathDirection = 8 then
  138.                   set gEndingPoint to point(the right of gDisplayArea - ((the right of gDisplayArea - the left of gDisplayArea) / 2), the bottom of gDisplayArea) - point(0, -logoHeight)
  139.                 else
  140.                   if gExitPathDirection = 9 then
  141.                     set gEndingPoint to point(the right of gDisplayArea, the bottom of gDisplayArea) - point(0, -logoHeight)
  142.                   end if
  143.                 end if
  144.               end if
  145.             end if
  146.           end if
  147.         end if
  148.       end if
  149.     end if
  150.   end if
  151.   updateAnimObjects(#exitPreview)
  152.   updateAnimObjects(#holdPreview)
  153.   updateAnimObjects(#enterPreview)
  154.   resetAnimationObjects()
  155.   cursor(-1)
  156.   callAnimEngine()
  157. end
  158.  
  159. on updatePreview
  160.   if gbCanAnimate and not gbPaused then
  161.     if gAnimationStage = #enter then
  162.       if (gEnterTime = 0) or (the pbPauseState of getaProp(gAnimationObjects, cLogoEnterChannel) = 1) then
  163.         set gAnimationStage to #hold
  164.         setVisibleState(getaProp(gAnimationObjects, cLogoHoldChannel), 1)
  165.         setVisibleState(getaProp(gAnimationObjects, cLogoEnterChannel), 0)
  166.         set the pStartTicks of getaProp(gAnimationObjects, cLogoHoldChannel) to the ticks
  167.         set the pOffsetTicks of getaProp(gAnimationObjects, cLogoHoldChannel) to the ticks
  168.         setPauseState(getaProp(gAnimationObjects, cLogoHoldChannel), 0)
  169.         callAnimEngine()
  170.       else
  171.         exit
  172.       end if
  173.     end if
  174.     if gAnimationStage = #hold then
  175.       if (gHoldTime = 0) or (the pbPauseState of getaProp(gAnimationObjects, cLogoHoldChannel) = 1) then
  176.         set gAnimationStage to #exit
  177.         setVisibleState(getaProp(gAnimationObjects, cLogoExitChannel), 1)
  178.         setVisibleState(getaProp(gAnimationObjects, cLogoHoldChannel), 0)
  179.         set the pStartTicks of getaProp(gAnimationObjects, cLogoExitChannel) to the ticks
  180.         set the pOffsetTicks of getaProp(gAnimationObjects, cLogoExitChannel) to the ticks
  181.         setPauseState(getaProp(gAnimationObjects, cLogoExitChannel), 0)
  182.         callAnimEngine()
  183.       else
  184.         exit
  185.       end if
  186.     end if
  187.     if gAnimationStage = #exit then
  188.       if (gEnterTime = 0) or (the pbPauseState of getaProp(gAnimationObjects, cLogoExitChannel) = 1) then
  189.         setVisibleState(getaProp(gAnimationObjects, cLogoExitChannel), 0)
  190.         set gAnimationStage to #delay
  191.         startTimer()
  192.       else
  193.         exit
  194.       end if
  195.     end if
  196.     if gAnimationStage = #delay then
  197.       if the timer > (value(word 1 of field "DelayTime") * 60) then
  198.         set gLoopCounter to gLoopCounter + 1
  199.         if (gGeneralSetting = #once) or ((gGeneralSetting = #nTimes) and (gLoopCounter >= gLoopMaximum)) then
  200.           set gbCanAnimate to 0
  201.         else
  202.           resetAnimationObjects()
  203.         end if
  204.       end if
  205.     end if
  206.   end if
  207. end
  208.  
  209. on resetAnimationObjects
  210.   set gAnimationStage to #enter
  211.   set the loc of sprite cLogoEnterChannel to gStartingPoint
  212.   set the loc of sprite cLogoHoldChannel to gCenterStage
  213.   set the loc of sprite cLogoExitChannel to gCenterStage
  214.   updateStage()
  215.   set enterOBJ to getaProp(gAnimationObjects, cLogoEnterChannel)
  216.   set the pCurrentFrame of enterOBJ to 1
  217.   set the pLoopCounter of enterOBJ to 0
  218.   set the pCurrentTime of enterOBJ to 0
  219.   set the pCurrentPathFrame of enterOBJ to 1
  220.   set the pStartTicks of enterOBJ to the ticks
  221.   set the pOffsetTicks of enterOBJ to the ticks
  222.   set the pCurrentLoc of enterOBJ to the pPathStartLoc of enterOBJ
  223.   setVisibleState(enterOBJ, 1)
  224.   set the pbPauseState of enterOBJ to 0
  225.   set holdOBJ to getaProp(gAnimationObjects, cLogoHoldChannel)
  226.   set the pCurrentFrame of holdOBJ to 1
  227.   set the pLoopCounter of holdOBJ to 0
  228.   set the pCurrentTime of holdOBJ to 0
  229.   set the pCurrentPathFrame of holdOBJ to 1
  230.   set the pCurrentLoc of holdOBJ to the pPathStartLoc of holdOBJ
  231.   set exitOBJ to getaProp(gAnimationObjects, cLogoExitChannel)
  232.   set the pCurrentFrame of exitOBJ to 1
  233.   set the pLoopCounter of exitOBJ to 0
  234.   set the pCurrentTime of exitOBJ to 0
  235.   set the pCurrentPathFrame of exitOBJ to 1
  236.   set the pCurrentLoc of exitOBJ to the pPathStartLoc of exitOBJ
  237.   callAnimEngine()
  238. end
  239.  
  240. on pushSprites firstChannel, lastChannel
  241.   set gSpriteStack to [:]
  242.   repeat with channel = firstChannel to lastChannel
  243.     set props to [:]
  244.     addProp(props, #puppet, the puppet of sprite channel)
  245.     addProp(props, #loc, the loc of sprite channel)
  246.     addProp(props, #castNum, the castNum of sprite channel)
  247.     addProp(props, #ink, the ink of sprite channel)
  248.     addProp(props, #stretch, the stretch of sprite channel)
  249.     addProp(gSpriteStack, channel, props)
  250.   end repeat
  251. end
  252.  
  253. on clearSprites firstChannel, lastChannel
  254.   repeat with channel = firstChannel to lastChannel
  255.     puppetSprite(channel, 0)
  256.   end repeat
  257. end
  258.  
  259. on popSprites
  260.   set channelCount to count(gSpriteStack)
  261.   repeat with element = 1 to channelCount
  262.     set channel to getPropAt(gSpriteStack, element)
  263.     set props to getaProp(gSpriteStack, channel)
  264.     set the puppet of sprite channel to the puppet of props
  265.     set the loc of sprite channel to the loc of props
  266.     set the castNum of sprite channel to the castNum of props
  267.     set the ink of sprite channel to the ink of props
  268.     set the stretch of sprite channel to the stretch of props
  269.   end repeat
  270. end
  271.  
  272. on addLists masterList, listToAdd
  273.   if not listp(masterList) then
  274.     if masterList <> EMPTY then
  275.       exit
  276.     end if
  277.     set theDataType to getIlk(listToAdd)
  278.     if theDataType = #linearList then
  279.       set masterList to []
  280.     else
  281.       if theDataType = #propertyList then
  282.         set masterList to [:]
  283.       else
  284.         exit
  285.       end if
  286.     end if
  287.   end if
  288.   if not listp(listToAdd) and (listToAdd <> EMPTY) then
  289.     exit
  290.   end if
  291.   if getIlk(masterList) <> getIlk(listToAdd) then
  292.     exit
  293.   end if
  294.   if getIlk(masterList) = #linearList then
  295.     set newItemCount to count(listToAdd)
  296.     repeat with x = 1 to newItemCount
  297.       add(masterList, getAt(listToAdd, x))
  298.     end repeat
  299.   else
  300.     set newItemCount to count(listToAdd)
  301.     repeat with x = 1 to newItemCount
  302.       addProp(masterList, getPropAt(listToAdd, x), getAt(listToAdd, x))
  303.     end repeat
  304.   end if
  305. end
  306.  
  307. on getIlk data
  308.   if listp(data) then
  309.     if ilk(data, #propList) then
  310.       set theIlk to #propList
  311.     else
  312.       set theIlk to #linearList
  313.     end if
  314.   else
  315.     set theIlk to ilk(data)
  316.   end if
  317.   return theIlk
  318. end
  319.